<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<script type="text/javascript" src="<%=basePath%>/js/jquery-2.1.4.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/xjj_sso_jsonp.js"></script>
	
	<script type="text/javascript">
		function logon()
		{
			xjjsso.ssoLogonByJsonp("ssoForm",function(ssoUser){
				alert(ssoUser);
				//var obj = eval('(' + str + ')');
				//alert("前台得到了sso用户="+ssoUser);
			
			});
		}
		
		function logout()
		{
			xjjsso.ssoSignoutByJsonp(function(msg){
			
				alert("退出成功="+msg);
			
			});
		}
		
		function getSSOUser()
		{
			xjjsso.ssoAuthenticationByJsonp(function(ssoUser){
			
				var json = eval('(' + ssoUser + ')');
				console.info(json);
				alert(json.user.userName);
				//alert("验证前台得到了sso用户="+ssoUser);
			});
		}
	</script>
  </head>
  
  <body>
	<h1>sso jsonp登陆</h1>
  	<hr/>
    <form id="ssoForm">
    	账号:<INPUT TYPE="text" NAME="identity" value=""><br/>
    	密码:<INPUT TYPE="text" NAME="password" value=""><br/>
    	<br/>
		<INPUT TYPE="button" onclick="logon();" value="登陆">
		<INPUT TYPE="button" onclick="logout();" value="退出">
   	 	<INPUT TYPE="button" onclick="getSSOUser();" value="查看登陆用户">
    </form>
  </body>
</html>
